home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
varia
/
egebook.lha
/
ege.book
/
1
/
Scheduling.C
< prev
Wrap
C/C++ Source or Header
|
1992-06-04
|
2KB
|
67 lines
#include <stdio.h>
class Teacher {
char *name; // name of teacher
public:
void setName(char *newName){ // member function
name = newName;
};
void print(){
printf("the teachers name is: %s \n", name);
};
};
class Student{
char *name; // name of student
};
class Course {
char *number; // course number as string
char *time; // time slot as string
Student *students[25]; // array of students in class
public:
Teacher *teacher; // teacher for class
void initialize(char *n, char *t){
number = n;
time = t;
};
};
class Schedule {
Course *offerings[10]; // array of courses
int offered; // number of courses offered
public:
Schedule():offered(0){};
void assign(Course *c, Teacher *t){
if (offered < 10) {
offerings[offered++] = c;
c->teacher = t; // NOTE: teacher field of course c
// is accessed with operator "->"
} else
printf("Schedule full ! \n");
};
};
main() {
Schedule s; // a schedule object
Teacher t1, t2; // teacher objects
Course c1, c2; // course objects
t1.setName("Joe Teach");
t2.setName("John Prof");
c1.initialize("COP 4225","MW 1030-1200");
c2.initialize("COP 6611","TR 1030-1200");
printf("Welcome to the Course Scheduling system\n");
s.assign(&c1, &t1); // assign function expects
s.assign(&c2, &t2); // pointer arguments
printf("Teacher of first course: ");
c1.teacher->print();
printf("Teacher of second course: ");
c2.teacher->print();
// ... rest of application
}